home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8372 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.8 KB  |  102 lines

  1. Path: american.edu!JW1675A
  2. From: JW1675A@american.edu (James D. Watson)
  3. Newsgroups: comp.lang.c
  4. Subject: Can't debug into a function; likely a code problem
  5. Date: Sun, 03 Mar 96 14:00:11 EST
  6. Organization: The American University
  7. Message-ID: <1773FC4EBS86.JW1675A@american.edu>
  8. NNTP-Posting-Host: auvm.american.edu
  9.  
  10. Good afternoon --
  11. I'm having a problem that has manifested itself in a very odd way: While
  12. debugging my program I cannot step into this function, although it seems to
  13. return ok, and runs ok outside the debugger.  (Yes, compiled with debugging
  14. on ;-)
  15.  
  16. Platform: Sun SPARC2, SunOS 4.1.3, using ANSI C and dbx.
  17.  
  18. Here's the manner of the code:
  19.  
  20. typedef struct {
  21.   ...
  22. } tsType1;
  23.  
  24. typedef struct {
  25.   ...
  26. } tsType2;      /* tsType1 and tsType2 are different sizes with
  27.                    different elements */
  28.  
  29. typedef struct {
  30.    char sData[100];
  31.    tsType1 *t1;
  32.    tsType2 *t2;
  33. } tsRecord;
  34. typedef enum { getType1, getType2 } TYPE_TO_GET;
  35.  
  36. /*************************************************/
  37. main(...)  {
  38.   extractData(argv[1]);
  39.   ...
  40. }
  41.  
  42. /*************************************************/
  43. int extractData(const char *sFilename) {
  44.   tsRecord rec;
  45.   ...
  46.   if(!readRecord(sFilename, getType1, (void*)&(rec.t1))) {
  47.     /* error */
  48.   }
  49.   ...
  50. }
  51.  
  52. /*************************************************/
  53. bool readRecord(const char *sFilename, const TYPE_TO_GET eWhich,
  54.                 (void**)ptr) {
  55.  
  56.    FILE *f;
  57.    ...
  58.     /* nothing done with f or any of the parameters yet */
  59.    if(!openFile(&f, eWhich, "rb", (const char *sFilename))) {
  60.      /* error */
  61.    }
  62.    ...    /* do normal casting of ptr, malloc() for it, and fill it*/
  63.   return(TRUE);
  64. }
  65.  
  66. /*************************************************/
  67. bool openFile(FILE **f, const TYPE_TO_GET eWhich, const char *sMode,
  68.               const char *sFilename) {
  69.  
  70.      ...
  71.     *f=fopen(sFilename, sMode);
  72.     if(*f==(FILE*)NULL) {
  73.       perror(sFilename);
  74.       return(FALSE);
  75.     }
  76.     ...
  77.   return(TRUE);
  78. }
  79.  
  80. /* end code example */
  81.  
  82. It's  this last function -- openFile() -- that I can't step into.
  83. I can get into readRecord() fine.  Once I step into the openFile() call,
  84. I get into some assembler code (sethi %.. %g1).  It's almost as if this
  85. one particular function didn't get compiled with debugging info, but it
  86. did -- it's all part of one file with the other functions (only main() is
  87. in another .c file).
  88.  
  89. Anyway, if I do "dump" (dbx-ese for "show all local variables), sometimes
  90. I have a <bad address> for one of the temporary variables -- labeled
  91. #tmpnn on this system -- and I have no idea what that is a reference for.
  92.  
  93. So, even though the function seems to work fine, I have a paranoid feeling
  94. that this is symptomatic of a larger problem.  I've included a malloc()
  95. debugging library, and it notices no problems.
  96.  
  97. Your wisdom, as always, is appreciated.
  98.  
  99. Regards,
  100. Jim
  101.                  --- Standard disclaimers apply ---
  102.